<!-- 深圳交易 登录跳转中间页面 -->
<template>
  <div>
    <a-spin size="large" tip="系统登录中...">
    <div class="callbackSso">
    </div>
  </a-spin>
  <personSelect v-if="visible" @ok="ok" :visible="visible" :submitLoading="submitLoading" @cancel="cancel"></personSelect>
  </div>
  
</template>

<script>
import {syncLogin,loginUserInfo} from '@/api/sso'
import storage from '@/utils/storage'
import personSelect from '@/components/base/personSelect'
import {qryUserRefDetail} from "@/api/login";

export default {
  components: {personSelect},
  props: [],

  data() {
    return {
      userToken: '',
      jumpType: '',
      visible:false,
      submitLoading: false
    };
  },

  filter: {},

  computed: {},

  created() {
    
    this.userToken = this.$route.query.gldtoken;
  },

  mounted() {
      this.getLoginInfo()
  },

  watch: {},

  methods: {
    ok(user,userList) {
      storage.session.set('role', user.id)
      this.$store.commit('setRole', user.id)

      let roles = userList.map(item => {
        return item.id
      })
      storage.session.set('roles', roles)
      storage.session.set('isLogin', true)
      this.$router.push('/portal')
    },
    cancel() {
      this.visible = false
    },
    getLoginInfo() {
      const userToken = this.userToken
      let params = {
        userToken: userToken,
      }
      syncLogin(params).then(res => {
        if(res.code == 0) {
            let data = res.data
            storage.session.set('authToken', data.authToken)

            qryUserRefDetail().then(res => {
        if(res.code == 0) {
        res.data.userInfo.deptInfo = res.data.deptInfo

          storage.session.set('userInfo', res.data.userInfo)
          this.visible = true

        }
      })
        }
      }).catch(err =>{

      })
     
     
    }
  }
}

</script>
<style lang='scss' scoped>
/deep/.ant-spin-nested-loading>div>.ant-spin .ant-spin-text {
  position: fixed;
}

/deep/.ant-spin-nested-loading>div>.ant-spin-lg .ant-spin-text {
  padding-top: 20px;
  font-size: 20px;

}

.callbackSso {
  width: 100%;
  height: 100%;
  position: relative;
}
</style>
